using System;
using System.Configuration;
using System.ServiceModel;
using Domain;
using Interfaces;

namespace WcfClient
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			WSHttpBinding binding = new WSHttpBinding();
			EndpointAddress address = new EndpointAddress(ConfigurationManager.AppSettings["PersonServiceAddress"]);
			ChannelFactory<IPersonService> channelFactory = new ChannelFactory<IPersonService>(binding, address);
			IPersonService personService = channelFactory.CreateChannel();
			Console.WriteLine("Customer Full Name: " + personService.GetFullName(new Customer(Guid.NewGuid(), new Name("CustomerFirst", "CustomerMiddle", "CustomerLast"))));
			Console.WriteLine("Salesperson Full Name: " + personService.GetFullName(new Customer(Guid.NewGuid(), new Name("SalespersonFirst", "SalespersonMiddle", "SalespersonLast"))));
			Console.WriteLine("Salesperson Changed Name: " + personService.ChangeName(new Customer(Guid.NewGuid(), new Name("SalespersonFirst", "SalespersonMiddle", "SalespersonLast"))).FullName);

            GetIPersonFromService();
            Console.ReadLine();
        }

        private static void GetIPersonFromService()
        {
            WSHttpBinding binding = new WSHttpBinding();
            EndpointAddress address = new EndpointAddress(ConfigurationManager.AppSettings["PersonServiceAddress"]);
            ChannelFactory<IPersonService> channelFactory = new ChannelFactory<IPersonService>(binding, address);
            IPersonService personService = channelFactory.CreateChannel();

            IPerson person = personService.GetPerson();
            Console.WriteLine(person);
        }

	}
}